package com.base.self.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.base.result.PageUtils;
import com.base.result.ResponseResult;
import com.base.result.ResponseResultUtils;
import com.base.self.dto.selfOrderComment.SelfOrderCommentWebListDTO;
import com.base.self.entity.SelfOrderComment;
import com.base.self.mapper.SelfOrderCommentMapper;
import com.base.self.service.ISelfOrderCommentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

/**
 * <p>
 * 晒单 服务实现类
 * </p>
 *
 * @author XiFYuW
 * @since 2020-12-05
 */
@Service
public class SelfOrderCommentServiceImpl extends ServiceImpl<SelfOrderCommentMapper, SelfOrderComment> implements ISelfOrderCommentService {

    @Override
    @Transactional(readOnly = true)
    public ResponseResult selfOrderCommentWebList(SelfOrderCommentWebListDTO selfOrderCommentWebListDTO) {
        final Map<String, Object> data = PageUtils.getDateMap(() -> page(PageUtils.getPage(
                new Page<>(), selfOrderCommentWebListDTO.getOffset(), selfOrderCommentWebListDTO.getLimit()),
                new LambdaQueryWrapper<SelfOrderComment>()
                        .eq(SelfOrderComment::getIsDel, 0)
                        .orderByDesc(SelfOrderComment::getCreateTime)));
        return ResponseResultUtils.getResponseResultS("查询成功", data);
    }
}
